package com.yl.rabbitmq.day02;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.yl.rabbitmq.utils.RabbitMQUtil;

/**
 * @author yangl
 */
public class Consumer02 {
    /**
     * 队列的名称
     */
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtil.getChannel();
        //声明接收消息
        DeliverCallback deliverCallback = (consumerTag, message)->{
            System.out.println("接收到的消息：" + new String(message.getBody()));
        };
        //声明取消接收消息
        CancelCallback cancelCallback = consumerTag -> {
            System.out.println("消息被消费者取消消费接口回调逻辑");
        };
        System.out.println("c3等待消息....");
        //消息的接收
        channel.basicConsume(QUEUE_NAME, true, deliverCallback, cancelCallback);
    }
}
